// coupon.js
var api = require('../../../config/api.js');
var util = require('../../../utils/util.js');
const app = getApp();

Page({

  /**
   * 页面的初始数据
   */
  data: {
    cnavbar:['红包余额','红包明细'],
    currentTab:0,
    coupon:{},
    sumLeft:'',
    billList:{}
  },
  navbarTap:function(e){
    this.setData({
      currentTab: e.currentTarget.dataset.idx
    })
  },
  picker:function(){
    wx.navigateTo({
      url: '../picker/picker',
    })
  },
  //优惠券数据加载
  coupon:function(){
    var that = this
    util.request(api.CouponUrl, { unionid: app.globalData.unionid }).then(function(res){
       if(res.data.code == 200){
         that.setData({
           sumLeft: res.data.data,
           billList: res.data.data.coupons,
           bgColor: "#fff"
         })
       }
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.coupon()
  }

})